Skip to content

feat(extra-natives/five): GET_WEAPON_ACCURACY_SPREAD & SET_WEAPON_ACC… #3356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bleenobtw
Copy link
Contributor

Goal of this PR

Introduces a way for client scripts to get & set the accuracy spread value of a weapon via it's hash.

How is this PR achieving the goal

By introducing GET_WEAPON_ACCURACY_SPREAD & GET_WEAPON_ACCURACY_SPREAD to allow client scripts to retrieve and set the spread of a weapon.

This PR applies to the following area(s)

FiveM, Natives

Successfully tested on

Game builds: 2062, 3095, 3258

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

@github-actions github-actions bot added the triage Needs a preliminary assessment to determine the urgency and required action label Apr 23, 2025
@dalekenium-cfx dalekenium-cfx self-assigned this Apr 24, 2025
@dalekenium-cfx dalekenium-cfx added the ready-to-merge This PR is enqueued for merging label Apr 24, 2025
@dalekenium-cfx
Copy link
Contributor

Looks good.

accuracy_spread = *(int*)(weapon + weapon_spread_offset);
}

context.SetResult<int>(accuracy_spread);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why in GET we return it as int and in SET we set float?


if (auto weapon = getWeaponFromHash(context))
{
accuracy_spread = *(int*)(weapon + weapon_spread_offset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use hook::FlexStruct to make this code easier to read please?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And same notice about variable name styling

@@ -354,6 +355,7 @@ static HookFunction hookFunction([]()
WeaponDamageModifierOffset = *hook::get_pattern<int>("48 8B 0C F8 89 B1", 6);
WeaponAnimationOverrideOffset = *hook::get_pattern<int>("8B 9F ? ? ? ? 85 DB 75 3E", 2);
WeaponRecoilShakeAmplitudeOffset = *hook::get_pattern<int>("48 8B 47 40 F3 0F 10 B0 ? ? ? ?", 8);
weapon_spread_offset = *hook::get_pattern<uint8_t>("F3 0F 59 59 ? F3 0F 59 D8", 4);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use same name styling as above please

@prikolium-cfx prikolium-cfx removed the ready-to-merge This PR is enqueued for merging label Apr 24, 2025
Copy link
Collaborator

@prikolium-cfx prikolium-cfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do requested changes.

@bleenobtw bleenobtw requested a review from prikolium-cfx April 25, 2025 01:01
@n3xuuu
Copy link
Contributor

n3xuuu commented Apr 25, 2025

@bleenobtw can you squash the commits? and they're most likely going to merge this pull request. 😁

@bleenobtw
Copy link
Contributor Author

@bleenobtw can you squash the commits? and they're most likely going to merge this pull request. 😁

They get squashed when merged.

@prikolium-cfx
Copy link
Collaborator

@bleenobtw can you squash the commits? and they're most likely going to merge this pull request. 😁

They get squashed when merged.

No, they don't. We are not merging using GitHub, I'm doing it manually and if I squash your commits on my side - I will be mentioned as "committed by".
Could you please squash them on your side and force push all your changes as one commit.

…URACY_SPREAD

feat(extra-natives/five): fix variable naming conventions, using flexstruct and getter now uses a float
@bleenobtw bleenobtw force-pushed the feat/accuracy-spread-natives branch from 6bb79d3 to c73d9da Compare April 29, 2025 07:15
@bleenobtw
Copy link
Contributor Author

@bleenobtw can you squash the commits? and they're most likely going to merge this pull request. 😁

They get squashed when merged.

No, they don't. We are not merging using GitHub, I'm doing it manually and if I squash your commits on my side - I will be mentioned as "committed by". Could you please squash them on your side and force push all your changes as one commit.

Sorry for the confusion, should be good! Thanks for the review.

Copy link
Collaborator

@prikolium-cfx prikolium-cfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution

@prikolium-cfx prikolium-cfx added the ready-to-merge This PR is enqueued for merging label Apr 29, 2025
@prikolium-cfx prikolium-cfx merged commit f4640db into citizenfx:master May 1, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR is enqueued for merging triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants